package puyu.manage.service.report.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import puyu.manage.service.common.config.BaseController;
import puyu.manage.service.common.page.TableDataInfo;
import puyu.manage.service.constant.AjaxResult;
import puyu.manage.service.report.service.ReportService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
 * 报告表(PuyuTReport)表控制层
 *
 * @author whl
 * @since 2024-06-17 18:24:40
 */
@RestController
@Api(tags = "报告表数据处理")
@RequestMapping("/puyuTReport")
public class ReportController extends BaseController{
    /**
     * 服务对象
     */
    @Resource
    private ReportService reportService;

    /**
     * 分页查询
     *
     * @return 查询结果
     */
	@ApiOperation(value = "分页查询")
    @PostMapping(value ="/getPageList", produces = { "application/json; charset=UTF-8" })
    public TableDataInfo getTableList(@ApiParam(name="params",
                    value="参数集合:pageNum-第几页;pageSize-每页多少条;orderByColumn-排序列;isAsc-正序倒序",required=true) @RequestParam Map<String,Object> params) {
		startPage();//需传pageNum pageSize orderByColumn（排序列 ） isAsc（正序倒序）
        //根据条件分页查询列表
        List<Map<String,Object>> list = reportService.getPageList(params);
		return getDataTable(list);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @ApiOperation(value = "单条查询")
    @GetMapping("/queryById/{id}")
    public AjaxResult queryById(@PathVariable("id") String id) {
        return AjaxResult.success(reportService.queryById(id));
    }

    /**
     * 报告二维码生成
     *
     * @return 编辑结果
     */
    @ApiOperation(value = "报告二维码生成")
    @PostMapping("/editReportCode")
    public AjaxResult editReportCode(@ApiParam(name="params",
            value="参数集合:datas-页面操作的数据;",required=true) @RequestParam Map<String,Object> params) {
        return AjaxResult.success(reportService.editReportCode(params));
    }

    /**
     * 报告单二维码扫码次数增加
     *
     */
    @ApiOperation(value = "报告单二维码扫码次数增加")
    @GetMapping(value = "/updateReportNum/{id}")
    public AjaxResult updateReportNum(@PathVariable("id") String id) {
        return AjaxResult.success(reportService.updateReportNum(id));
    }


    /**
     * 报告查询未上传视频的任务单
     *
     */
    @ApiOperation(value = "报告查询未上传视频的任务单")
    @GetMapping(value = "/queryTaskVideoById/{id}")
    public AjaxResult queryTaskVideoById(@PathVariable("id") String id) {
        return AjaxResult.successMsg(reportService.queryTaskVideoById(id));
    }
}

